<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
  <script th:src="@{/}+'js/underscore.js'"></script>
  <script th:src="@{/}+'layuiadmin/plugins/xm-select/xm-select.js'"></script>
  <style type="text/css">
	.layui-form .layui-form-item{
		width:90%;
	}
	.layui-input-inline{
		width:170px!important
	}
	</style>
	<script th:inline="javascript">
/*<![CDATA[*/
var id=/*[[${id}]]*/     
var userId=/*[[${session.me.id}]]*/     
var userName=/*[[${session.me.name}]]*/     
/*]]>*/
</script>

</head>
<body style="margin-top: 10px">
<form class="layui-form" lay-filter="myform" id="myform">
<input type="hidden" name="id">
  <div class="layui-form-item">
    <label class="layui-form-label">角色名称</label>
    <div class="layui-input-inline">
      <input type="text" name="name" lay-verify="required" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">角儿编码</label>
    <div class="layui-input-inline">
      <input type="text" name="code" lay-verify="required" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">所属公司</label>
    <div class="layui-input-inline">
      <select name="orgId" id="orgId" lay-filter='orgId'></select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">排序</label>
    <div class="layui-input-inline">
      <input type="number" name="orderno" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">备注说明</label>
    <div class="layui-input-block">
      <input type="text" name="descs" autocomplete="off" class="layui-input">
    </div>
  </div>
  <button id="submitBtn" class="layui-btn" style="display:none" lay-submit lay-filter="submitme">保存</button>
</form>
 
<script>
layui.use(['form', 'table', 'laydate'], function(){
	  var form = layui.form
	  ,layer = layui.layer
	  ,treeSelect = layui.treeSelect
	  ,table = layui.table
	  ,laydate = layui.laydate;
	  select('org/getList?parentId=' , 'orgId',form,"name",'id')
	form.on('submit(submitme)', function(data){
			var values = {};
			$(":input").each(function(i,v){
				values[v.name] = v.value;
			})
			axios.post('role/save',values).then(res=>{
				if(res.code==1){
					layer.msg(ret.msg);
				}else{
					parent.loadGrid(res.id);
					layer.msg( '保存成功');
					var index = parent.layer.getFrameIndex(window.name); 
				    parent.layer.close(index); 
				}
			})
			return false; 
	});
	if(id){
		  loadData();
	}
	function loadData(){
		var entity = getEntityInfo(id,"role/getById");
        form.val("myform",entity);
	}
	  
})
</script>
</body>
</html>